﻿namespace Generator
{
    class FuncsReal : IFuncs
    {
        public object Return(object a)
        {
            return a;
        }

        public object Const(int a)
        {
            return a;
        }

        public object Param(object[] paramsList, int number)
        {
            return paramsList[number];
        }

        public object ElemInt(object list, object number)
        {
            return ((object[])list)[(int)number];
        }

        public object ElemList(object list, object number)
        {
            return ((object[])list)[(int)number];
        }

        public object Add(object a, object b)
        {
            return (int)a + (int)b;
        }

        public object Sub(object a, object b)
        {
            return (int)a - (int)b;
        }

        public object Mul(object a, object b)
        {
            return (int)a * (int)b;
        }

        public object Div(object a, object b)
        {
            return (int)a / (int)b; 
        }

        public object MakePair(object a, object b)
        {
            return new[] { a, b };
        }

        public object MakeClosure(string name, Function func)
        {
            return func;
        }

        public object Call(Function func, params object[] args)
        {
            return func.Invoke(new object[] { args });
        }

        public object IfEqual(object a, object b)
        {
            return (int)a == (int)b;
        }

        public object IfGreater(object a, object b)
        {
            return (int)a > (int)b;
        }

        public object IfGreaterOrEqual(object a, object b)
        {
            return (int)a >= (int)b;
        }

        public object Select(object flag, object ifTrue, object ifFalse)
        {
            return (bool)flag ? ifTrue : ifFalse;
        }

        public void Flush()
        {
        }
    }
}
